package org.nokatag.system;

import java.net.URL;
import java.net.URLClassLoader;

/**
 * <p>@Title </p>
 * <p>@Description 服务器方法调用</p>
 * <p>@Version 1.0.0</p>
 * <p>@author rebin</p>
 * <p>@date 2017年6月20日</p>
 * <p>xiefangjian@163.com</p>
 * <p>Copyright © Noka Laboratory.All Rights Reserved.</p>
 */
public class NLoadFun  extends SpringObjectFactory{

	@SuppressWarnings("rawtypes")
	public Object getBean(String path){
		//----------------spring装配----------------------------------------------
		try{
			if(path.startsWith(Concest.SPRING_STARTS_WITH)){
				return bulidBean(path.substring(Concest.SPRING_STARTS_WITH.length()));
			}
		}catch(Exception se){}
		//-----------------普通装配---------------------------------------------------
		try{
			Class myClass  = null;
			try{
				myClass =Class.forName(path);
			}catch(Exception se){}
			if(null==myClass){
				URL url = new URL("file:" + Concest.ROOTDIR + "WEB-INF/classes");
				URL url2 = new URL("file:" + Concest.ROOTDIR + "WEB-INF/lib");
				URLClassLoader myClassLoader = new URLClassLoader(new URL[] { url,url2 }, Thread.currentThread().getContextClassLoader());
				myClass = myClassLoader.loadClass(path);
			}
			return myClass.newInstance();
		}catch(Exception se){
		}
		return null;
	}
}
